<section class="content-header" >
	<h1>
		用户管理
		<small>用户列表</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="{:U('Admin/index')}"><i class="fa fa-home"></i>首页</a></li>
		<li class="active">用户列表</li>
	</ol>
</section>
<!-- Main content -->
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<div class="box">
				<div class="box-header">
					<div class="box-title"><label >角色列表</label></div>
					<div class="pull-right">
						<button class="btn btn-block btn-primary btn-sm" onclick="adminMemberEdit(0)"><i class="fa fa-plus"></i>&nbsp;&nbsp;&nbsp;添加用户</button>
					</div>
				</div><!-- /.box-header -->
				<div class="box-body">
					<table id="table" class="table table-bordered table-striped" width="100%">
						<thead>
							<tr>
								<th>用户名</th>
								<th>所属角色</th>
								<th>最后登录IP</th>
								<th>最后登录时间</th>
								<th>E-mail</th>
								<th>真实姓名</th>
								<th>站点</th>
								<th>操作</th>
							</tr>
						</thead>
					</table>
				</div><!-- /.box-body -->
			</div><!-- /.box -->
		</div><!-- /.col -->
	</div><!-- /.row -->
</section><!-- /.content -->
<!-- page script -->
<script type="text/javascript">
	$(function () {
		$('#table').dataTable({
			"processing": true, //载入数据的时候是否显示“载入中”
			"ordering": false, //排序操作在服务端进行，所以可以关了。
			"searching": false,
			'serverSide': true,
			ajax: {
				"url": "{:U('Admin/memberList')}",
				"type": "POST"
			},
			"columns": [
				{"data": "username"},
				{"data": "rolename","orderable":false},
				{"data": "lastloginip","orderable":false},
				{"data": "lastlogintime","orderable":false},
				{"data": "email","orderable":false},
				{"data": "realname","orderable":false},
				{"data": "sitename","orderable":false},
				{"data": "userid","orderable":false}
			],
			"columnDefs": [
				{
					"targets": 7,
					"render": function (data, type, row) {
						return '<a href="javascript:adminMemberEdit(' +data + ')"><i class="fa fa-edit"></i>&nbsp;编辑</a>' +
								'&nbsp;&nbsp;&nbsp;<a href="javascript:adminMemberDelete(' +data + ')"><i class="fa fa-trash-o"></i>&nbsp;删除</a>';
					}
				}
			],
			"language": lang
		});
	});

	//编辑
	function adminMemberEdit(id){
		var url = "{:U('Admin/memberEdit')}";
		url += url.indexOf('?') != -1 ? '&id='+id : '?id='+id;
		$.dialog(url,"修改用户信息",null,46);
	}

	//删除
	function adminMemberDelete(id){
		$.messager.confirm('提示信息', '确定要删除吗？', function(result){
			if(!result) return false;
			$.post("{:U('Admin/memberDelete')}", {id: id}, function(res){
				if(!res.status){
					$.messager.alert('提示信息', res.info, 'error');
				}else{
					$.messager.alert('提示信息', res.info, 'info');
					reloadContent();
				}
			}, 'json');
		});
	}
</script>